package com.hq.ims.userpc.busservice;

import com.hq.ims.data.service.BaseBusInfoForewarningService;
import com.hq.ims.data.utils.WebExpandUtils;
import com.hq.ims.data.vo.BusInfoForewarningMapstruct;
import com.hq.mybatis.base.page.RequestPage;
import com.hq.mybatis.base.page.ReturnPage;
import com.hq.utils.util.StringUtils;
import com.hq.utils.vo.ReturnVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author cx
 * @date 2024/11/26 11:21:02
 * @description 经营信息预警Service
 */
@Service
public class UserBusiInfoForewarningService {

    @Resource
    private BaseBusInfoForewarningService baseBusInfoForewarningService;

    /**
     * 经营信息预警分页查询
     *
     * @param page     分页对象
     * @param searchVo 查询条件
     * @return ReturnVo
     */
    public ReturnVo<ReturnPage<BusInfoForewarningMapstruct.BusInfoForewarningVo>> pageList(RequestPage<BusInfoForewarningMapstruct.BusInfoForewarningVo> page,
                                                                                           BusInfoForewarningMapstruct.PageSearchVo searchVo) {
        if (StringUtils.isEmpty(searchVo.getCompanyId())) {
            searchVo.setCompanyId(WebExpandUtils.getHeadCompanyId());
        }
        baseBusInfoForewarningService.getByPage(page, searchVo);
        return ReturnVo.buildSuccess(page.getReturnPage());
    }

    /**
     * 未接收预警详情
     *
     * @param busInfoForewarningId 预警id
     * @return ReturnVo
     */
    public ReturnVo<BusInfoForewarningMapstruct.NotReceiveDetailVo> getNotReceiveDetail(String busInfoForewarningId) {
        BusInfoForewarningMapstruct.NotReceiveDetailVo notReceiveDetailVo = baseBusInfoForewarningService.getNotReceiveDetail(busInfoForewarningId);
        return ReturnVo.buildSuccess(notReceiveDetailVo);
    }

    /**
     * 未反馈预警详情
     *
     * @param busInfoForewarningId 预警id
     * @return ReturnVo
     */
    public ReturnVo<BusInfoForewarningMapstruct.NotFeedbackDetailVo> getNotFeedbackDetail(String busInfoForewarningId) {
        BusInfoForewarningMapstruct.NotFeedbackDetailVo notFeedbackDetailVo = baseBusInfoForewarningService.getNotFeedbackDetail(busInfoForewarningId);
        return ReturnVo.buildSuccess(notFeedbackDetailVo);
    }

    /**
     * 发送预警短信
     *
     * @param forewarningSmsVo 发送短信对象
     * @return ReturnVo
     */
    public ReturnVo<Boolean> sendForewarningSms(BusInfoForewarningMapstruct.ForewarningSmsVo forewarningSmsVo) {
        Boolean flag = baseBusInfoForewarningService.sendForewarningSms(forewarningSmsVo);
        return ReturnVo.buildSuccess(flag);
    }
}
